package lol.clann.minecraft.springboot.api.spi.sbp;

import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * 子类通过java service loader来注册
 *
 * @author pyz
 * @date 2019/5/3 2:49 PM
 */
public interface ApplicationRunListener {
    /**
     * 按order升序触发
     *
     * @return
     */
    default int order() {
        return 0;
    }

    default void starting(SpringApplication application) {
    }

    default void environmentPrepared(SpringApplication application, ConfigurableEnvironment environment) {
    }

    default void contextPrepared(SpringApplication application, ConfigurableApplicationContext context) {
    }

    default void contextLoaded(SpringApplication application, ConfigurableApplicationContext context) {
    }

    default void started(SpringApplication application, ConfigurableApplicationContext context) {
    }

    default void running(SpringApplication application, ConfigurableApplicationContext context) {
    }

    default void failed(SpringApplication application, ConfigurableApplicationContext context, Throwable exception) {
    }
}
